package top.appx;

import java.io.*;

/**
 * Created by qq799 on 2017/1/15.
 */
public class Util {
    public static String readFile(String path) throws Exception {
        File file = new File(path);
        return readFile(file);
    }
    public static String readFile(File file) throws Exception {
        FileInputStream fis = new FileInputStream(file);
        byte[] bs=  new byte[fis.available()];
        fis.read(bs);
        String text = new String(bs,"utf-8");
        return text;
    }
    public  static void writeFile(String path,String text) throws Exception{
        File file = new File(path);
        file.delete();
        file.createNewFile();
        OutputStreamWriter wr = new OutputStreamWriter(new FileOutputStream(file),"utf-8");
        wr.write(text);
        wr.close();
    }
}
